using System;
using System.Diagnostics;

namespace Dida
{
	public class Ray
	{
		/// <summary>
		/// The point where the ray starts.
		/// </summary>
		public Vector3D start;
		/// <summary>
		/// The direction of the ray. This vector should always
		/// have a length of 1.
		/// </summary>
		public Vector3D dir;

		public Ray() { }

		/// <summary>
		/// Initializes this ray using the given parameters.
		/// </summary>
		/// <param name="start">The point of the ray</param>
		/// <param name="dir">The direction of the ray. This direction will
		/// be normalized if it doesn't have a length of 1.</param>
		public Ray(Vector3D start, Vector3D dir)
		{
			this.start = start;
			this.dir = dir;
			this.dir.Normalize();
		}

		/// <summary>
		/// Sets the dir to the direction of the given vector. The vector
		/// will be normalized if it doesn't have a length of 1.
		/// </summary>
		/// <param name="dir">The new direction for this ray</param>
		public void SetDir(Vector3D dir)
		{
			this.dir = dir;
			this.dir.Normalize();
		}
	}
}